#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use HTML::TableExtract;
use Data::Dump qw(pp);

use  constant URL=>'http://mirdb.org/cgi-bin/search.cgi';

my $ua=LWP::UserAgent->new;

my $searchType='miRNA';
my $full='mirbase';
my $searchBox='';
while(<DATA>){
my $response=$ua->post(URL,['searchType'=>$searchType,'full'=>$full,'searchBox'=>$_]);
my $html='';
if($response->is_success){
	$html=$response->content;
}else{
	print "ERROR\n";
}

#my $te=HTML::TableExtract->new(headers=>['Target', 'Detail','Target Rank',	'Target Score',	'miRNA Name',	'Gene Symbol',	'Gene Description']);
my $te=HTML::TableExtract->new(attribs=>{border=>1});
$te->parse($html);
for my $ts($te->tables){
	for my $row($ts->rows){
		print "@$row[1,2,3,4]","\n";
	}
}
exit;
}
__DATA__
MIMAT0000070
MIMAT0000072
MIMAT0000073
MIMAT0000075
MIMAT0000074
MIMAT0000092
MIMAT0000071
MIMAT0002891
MIMAT0004490
MIMAT0004493
MIMAT0004491
MIMAT0004507
